package ${content.service.classPackage!}<#if content.base.module?exists>.${content.base.module!}</#if>;

import ${content.base.basePacket!}.common.domain<#if content.base.module?exists>.${content.base.module!}</#if>.${content.entity.className!};
import ${content.base.basePacket!}.database.dao<#if content.base.module?exists>.${content.base.module!}</#if>.${content.dao.className!};
import ${content.base.basePacket!}.database.service.AbstractJpaService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * ${content.service.className!}的service
 *
 * @author  : ${content.base.author!}
 * @version : ${content.base.version!}
 * @date    : ${content.base.createTime!}
 */
@Service
public class ${content.service.className!} extends AbstractJpaService<${content.entity.className!}, String, ${content.dao.className!}> {

  /**
   * ${content.entity.className!}新增和修改
   *
   * @param ${content.entity.className?uncap_first} -
   *
   * @return -
   */
  @Transactional(rollbackFor = Exception.class)
  public ${content.entity.className!} saveOrUpdate(${content.entity.className!} ${content.entity.className?uncap_first}) {
    return getDao().saveAndFlush(${content.entity.className?uncap_first});
  }

  /**
   * ${content.entity.className!}删除
   * @param ids -
   */
  @Transactional(rollbackFor = Exception.class)
  public void delete(Iterable<java.lang.String> ids) {
    List<${content.entity.className!}> list = getDao().findAllById(ids);
    if(!CollectionUtils.isEmpty(list)){
      getDao().deleteInBatch(list);
    }
  }
}
